package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.SpuInfo;
import com.atguigu.gmall.product.service.BaseSpuInfoService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 卡尼奶
 * @Date 2022/5/18 19:42
 * @Version 1.0
 */

@RestController
@RequestMapping("/admin/product")
public class BaseSpuController {

    @Autowired
    private BaseSpuInfoService spuInfoService;

    /**
     * 分页查询Spu信息
     * @param page
     * @param limit
     * @param category3Id
     * @return
     */
    @GetMapping("/{page}/{limit}")
    public Result getSpuListPage(@PathVariable("page") Long page,@PathVariable("limit") Long limit,Long category3Id){
        Page<SpuInfo> spuInfoPage =  spuInfoService.getSpuListPage(page,limit,category3Id);
        return Result.ok(spuInfoPage);
    }

    @PostMapping("/saveSpuInfo")
    public Result saveSpuInfo(@RequestBody SpuInfo spuInfo){
        spuInfoService.saveSpuInfo(spuInfo);
        return Result.ok();
    }

}
